﻿using MvcApplication.Interface.Service.Weixin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcApplication.Controllers
{
    public class WeixinController : Controller
    {
        IMessageService _messageService;

        public WeixinController(IMessageService messageService)
        {
            _messageService = messageService;
        }

        public ActionResult Message()
        {
            string token = "findoout";
            if (string.IsNullOrEmpty(token))
            {
                return Content("Fail");
            }

            string echoString = Request.QueryString["echoStr"];
            string signature = Request.QueryString["signature"];
            string timestamp = Request.QueryString["timestamp"];
            string nonce = Request.QueryString["nonce"];

            _messageService.PushToWexin(Request.InputStream);

            if (!string.IsNullOrEmpty(echoString))
            {
                return Content(echoString);
            }

            return Content("Success");
        }

    }
}
